home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Games / Pentominoes 2.0 / Shell ƒ / file interface.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-29  |  2.1 KB  |  64 lines  |  [TEXT/MMCC]

  1. #include "file interface.h"
  2. #include "program globals.h"
  3. #include "window layer.h"
  4.  
  5. static    pascal Boolean CreatorFilterYD(CInfoPBPtr pb, Ptr unused);
  6.  
  7. Boolean GetSourceFile(FSSpec *sourceFS, ResType theType)
  8. /* a standard procedure which shows an open dialog box and returns the FSSpec of
  9.    the file you selected (or returns FALSE if you cancelled) */
  10. {
  11.     StandardFileReply    reply;
  12.     SFTypeList            theTypes;
  13.     Point                where;
  14.     FileFilterYDUPP        fileFilterUPP;
  15.     
  16.     DeactivateFloatersAndFirstDocumentWindow();
  17.     
  18.     fileFilterUPP=NewFileFilterYDProc(CreatorFilterYD);
  19.     theTypes[0]=theType;
  20.     where.h=where.v=-1;    /* will auto-center dialog */
  21. //    StandardGetFile(0L, 1, theTypes, &reply);
  22.     CustomGetFile(fileFilterUPP, 1, theTypes, &reply, 0, where, 0L, 0L, 0L, 0L, 0L);
  23.     DisposeRoutineDescriptor(fileFilterUPP);
  24.     
  25.     if (reply.sfGood)
  26.         FSMakeFSSpec(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name, sourceFS);
  27.     
  28.     ActivateFloatersAndFirstDocumentWindow();
  29.     
  30.     return reply.sfGood;    /* TRUE if we have a valid file selected */
  31. }
  32.  
  33. Boolean GetDestFile(FSSpec *destFS, Boolean *deleteTheThing, Str255 theTitle)
  34. /* a standard save dialog box -- given a title (for the prompt), it returns the
  35.    file's FSSpec in destFS and whether a file of that name already exists in
  36.    deleteTheThing (TRUE if file already exists) */
  37. /* details are pretty much the same as GetSourceFile(), see above */
  38. {
  39.     StandardFileReply    reply;
  40.     
  41.     DeactivateFloatersAndFirstDocumentWindow();
  42.     
  43.     StandardPutFile(theTitle, destFS->name, &reply);
  44.  
  45.     if (reply.sfGood)
  46.     {
  47.         *deleteTheThing=reply.sfReplacing;    
  48.         FSMakeFSSpec(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name,
  49.                         destFS);
  50.     }
  51.     
  52.     ActivateFloatersAndFirstDocumentWindow();
  53.     
  54.     return reply.sfGood;
  55. }
  56.  
  57. static    pascal Boolean CreatorFilterYD(CInfoPBPtr pb, Ptr unused)
  58. {
  59.     #pragma unused(unused)
  60.     
  61.     /* returns FALSE if file _should_ be shown; don't ask me why */
  62.     /* so using this file filter in GetSourceFile will only show folders and text files
  63.        with our application's creator */
  64.     return (((pb->hFileInfo.ioFlFndrIn